home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
host contacted
/
imengv3.41p2.lha
/
ImEngV3.41p2
/
Extra
/
ARexx
/
IndexChange.rexx
next >
Wrap
OS/2 REXX Batch file
|
1997-01-06
|
2KB
|
66 lines
/*
** $VER: IndexChange.rexx 1.05 (4/1 Stockholm/Sweden)
** Copyright © 1997 by Patrik M Nydensten
**
** Changes the index number for files.
** The new name will be the old basename but with another index number.
** The index number can be added or subtracted with a specified number.
** A positive number adds while a negative number subtracts.
**
** Usage: <add/sub_number> <first_index_file> <last_index_file>
*/
options results
parse arg num files
if pos('"',files) = 0 then parse var files file1 file2
else parse var files '"'file1'"' '"'file2'"'
number = strip(num)
if ~datatype(number,'N') then errorx('Error: Bad add/sub number.')
fix = strip(get_ext(file1)) ; lix = strip(get_ext(file2))
if ((~datatype(fix,'N'))|(~datatype(lix,'N'))) then errorx('Error: Bad index number in file name.')
fi = min(fix,lix) ; li = max(fix,lix)
if (fi+number) < 1 then errorx('Error: Add/sub number below 1.')
do i = fi to li
new_file = get_base(file1)'.'right(i+number,4,'0')
old_file = get_base(file1)'.'right(i,4,'0')
if exists(old_file) then do
address 'COMMAND' 'rename' '"'old_file'"' '"'new_file'!"'
end
else say 'Error: Could not locate file "'old_file'".'
end
do i = fi to li
new_file = get_base(file1)'.'right(i+number,4,'0')
if exists(new_file'!') then do
if ~exists(new_file) then address 'COMMAND' 'rename' '"'new_file'!"' '"'new_file'"'
else say 'Error: An image with that name already exist!'d2c(10)||,
' File: "'new_file'"'
end
end
exit
/* --[ proc ]--------------------------- */
errorx:
parse arg text
say text
exit 5
return 0
get_ext:
parse arg get_ext_in
if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in))
else get_ext_back = ''
return get_ext_back
get_base:
parse arg get_base_in
if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
else get_base_back = get_base_in
return get_base_back